//
//  statusForwardCell.swift
//  sinaWeiBo
//
//  Created by weixq on 15/8/7.
//  Copyright © 2015年 weixq. All rights reserved.
//

import UIKit

class statusForwardCell: StatueCell {
    
    // 重写属性 didSet不会覆盖父类的方法，之类只需要继续设置自己相关的内容就行
    // 需要和父类保持同样的行为
    override var status:Status? {
        didSet {
            let name = status?.retweeted_status?.user?.name ?? ""
            let text = status?.retweeted_status?.text ?? ""
            
            forwordLable.text = "@"+name+":"+text
        
        }
    }
    
    
    // 设置界面
    override func setupUI() {
        super.setupUI()
        
        // 排版测试
//        forwordLable.text = "ni shi zhu ma ni shi zhu ma ni shi zhu ma ni shi zhu ma ni shi zhu ma ni shi zhu ma ni shi zhu ma ni shi zhu ma ni shi zhu ma ni shi zhu ma ni shi zhu ma ni shi zhu ma ni shi zhu ma ni shi zhu ma ni shi zhu ma ni shi zhu ma ni shi zhu ma "
        
        // 1. 添加控件
        contentView.insertSubview(backButton, belowSubview: pictureView)
        contentView.addSubview(forwordLable)
        
        // 2. 设置布局
        backButton.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: contentLabel, size: nil, offset: CGPoint(x: -statusCellControlMargin, y: statusCellControlMargin))
        backButton.ff_AlignVertical(type: ff_AlignType.TopRight, referView: bottonView, size: nil)
        
        // 3. 转发文本
        forwordLable.ff_AlignInner(type: ff_AlignType.TopLeft, referView: backButton, size: nil, offset: CGPoint(x: statusCellControlMargin, y: statusCellControlMargin))
        
        // 4. 配图视图
        let cons = pictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: forwordLable, size: CGSize(width: 290, height: 290), offset: CGPoint(x: 0, y: statusCellControlMargin))
        
        pictureWidhtCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Width)
        pictureHightCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Height)
        pictureTopcons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Top)
    }
    
    
    
    // MARK: - 懒加载控件
    private lazy var forwordLable: UILabel = {
        
        let lab = UILabel(color: UIColor.darkGrayColor(), fontsize: 14)
        lab.numberOfLines = 0
        lab.preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * statusCellControlMargin
        return lab
    }()
    
    private lazy var backButton: UIButton = {
        
        let btn  = UIButton()
        btn.backgroundColor = UIColor(white: 0.9, alpha: 1.0)
        return btn
    }()
    
}
